#include "clickbtn.h"
#include <QDebug>
ClickBtn::ClickBtn(QWidget * parent):QPushButton(parent)
{
    setCursor(Qt::PointingHandCursor);
}

void ClickBtn::SetState(QString normal, QString hover, QString press)
{
    _hover = hover;
    _normal = normal;
    _press = press;
    mouseEvent(_normal);

}

void ClickBtn::enterEvent(QEvent *event)
{
    mouseEvent(_hover);
    QPushButton::enterEvent(event);
}

void ClickBtn::leaveEvent(QEvent *event)
{
    mouseEvent(_normal);
    QPushButton::enterEvent(event);
}

void ClickBtn::mousePressEvent(QMouseEvent *event)
{
     mouseEvent(_press);
    QPushButton::mousePressEvent(event);
}

void ClickBtn::mouseReleaseEvent(QMouseEvent *event)
{
    mouseEvent(_hover);
    QPushButton::mouseReleaseEvent(event);
}

void ClickBtn::mouseEvent(QString state)
{
    setProperty("state",state);
    repolish(this);
    update();
}
